<%--
  Created by IntelliJ IDEA.
  User: lichengming
  Date: 2017/8/3
  Time: 上午7:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/resources.jsp" %>
<html>
<head>
    <title>商品</title>
    <script>
        $(function () {
            $('#begin_time,#end_time').datetimepicker({
                language : 'zh-CN',
                format : 'yyyy-MM-dd HH:mm:ss',
            });
        })
    </script>
</head>
<body>
<div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">查询条件</h3>
        </div>
        <div class="panel-body">
            <form class="form-inline ems_search_form">
                <div class="form-group">
                    <button type="button" class="btn btn-info btn-search">查询</button>
                    <button type="button" class="btn btn-default btn-reset">清空</button>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="ems_table_content">
    <div class="panel panel-default">
        <div class="panel-heading">商家分类列表</div>
        <div id="table_tools">
            <div class="form-inline" role="form">
                <button type="button" id="shopsort_add" class="btn btn-outline btn-success">
                    <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
                    添加
                </button>
                <button type="button" id="shopsort_edit" class="btn btn-outline btn-primary">
                    <i class="glyphicon glyphicon-edit" aria-hidden="true"></i>
                    修改
                </button>
            </div>
        </div>
        <table id="shopsortTable"
               data-url="/ems/shopsort/pagination">
            <thead>
            <tr>
                <th data-field="state" data-checkbox="true"></th>
                <th data-field="name_" >商家分类名称</th>
                <th data-field="is_show_">商家类型</th>
            </tr>
            </thead>
        </table>
    </div>
</div>
<script>
    $(function () {

        $("#shopsortTable").createTable();

        var dialogOption = {
            width:"500px",
            height:"450px",
            url:"/ems/shopsort/edit",
            yesFn:function(){
                var result = shopSortSave();
                debugger;
                if (result) search('#shopsortTable',getQueryParams());
                return result;
            }
        }
        //添加
        $("#shopsort_add").on("click",function () {
            dialogOption.data = {};
            dialogOption.title = "新增分类";
            $("#system_param_add_dialog").openDialog(dialogOption);
        })

        //编辑
        $("#shopsort_edit").on("click",function () {
            var selectRows =  $('#shopsortTable').bootstrapTable('getSelections');
            if (selectRows.length == 0) {
                $.errorAlert("请选择要编辑的数据");
                return;
            }
            if (selectRows.length > 1) {
                $.errorAlert("暂时不支持多行数据编辑");
                return;
            }

            dialogOption.title = "分类编辑";
            dialogOption.data = {id : selectRows[0].id_};
            $("#system_param_add_dialog").openDialog(dialogOption);
        })
    });
</script>
<div id="system_param_add_dialog"></div>
</body>
</html>
